package com.hanserwei.mydemo.stream;

import java.util.stream.IntStream;

public class FindTest2 {
    public static void main(String[] args) {
        IntStream intStream1 = IntStream.of(1, 3, 5, 7, 9);
        IntStream intStream2 = IntStream.of(1, 2, 3, 4, 5, 6, 7, 8, 9);
        IntStream intStream3 = IntStream.of(1, 3, 5, 7, 9);

        System.out.println(intStream1.filter(x -> (x & 1) == 0).findFirst().orElse(-1));
        intStream2.filter(x -> (x & 1) == 0).findFirst().ifPresent(System.out::println);
        intStream3.filter(x -> (x & 1) == 0).findFirst().ifPresent(System.out::println);
    }
}
